Repository navigation
Omit empty properties from ability input schemas - #3491
Merged
brianhogg merged 1 commit intoNov 16, 2026
Merged
Conversation
sanitize_schema() always set `properties` to a PHP array for object nodes, so an object with no properties (such as `meta` on courses and lessons when no meta is registered) was encoded as `"properties": []`. JSON Schema requires an object there, and MCP clients drop the create/update course and lesson abilities because of it. Drop the keyword when it ends up empty. Fixes gocodebox#3484
Contributor
|
@theluckystrike Thanks for the PR! We normally don't add new |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Description
LLMS_REST_Ability_Factory::sanitize_schema()starts every object node with$sanitized['properties'] = array(). When the source object has no properties (for examplemetaon courses and lessons when no meta is registered for those post types), the empty PHP array is encoded as"properties": []. JSON Schema requirespropertiesto be an object, so MCP clients reject the whole input schema and thecreate-course,update-course,create-lessonandupdate-lessonabilities disappear from the tool list.This drops the keyword when it ends up empty, which is the first option suggested in the issue. An object schema without
propertiesmeans the same thing, and the WordPress REST validator doesn't need the key.Fixes #3484
How has this been tested?
test_input_schema_omits_empty_propertiestoLLMS_REST_Test_Ability_Factory. It builds the create input schema for courses and lessons and checks thatmetais still anobjectwith nopropertieskey and that the encoded schema contains no"properties":[]. It fails ondevand passes with this change.vendor/bin/phpunit --group rest_abilitiespasses (25 tests, 5 skipped as before) on PHP 8.5, WordPress latest.composer run-script check-cs-errorsreports nothing for the two touched PHP files.Types of changes
Bug fix (non-breaking change which fixes an issue)
Checklist: